// pages/goDutchBefore/childCpns/sign-up-history/sign-up-history.js
import {
  request,
  requestHasToken
} from '../../../../service/network'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    group: {
      type: Object,
      value: {}
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    group2: {
    },
    showModal: false,
    cancleBtn: true,
    modalMsg: '是否删除',
  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleView(e) {
      const id = e.currentTarget.dataset.id
      console.log(id);
      
      wx.navigateTo({
        url: '/pages/goDutch/goDutch?id=' + id
      })
    },
    del() {
      this.setData({
        showModal: true
      })
    },
    del2() {
      requestHasToken({
        url: 'api/go/dutch/remove',
        data: {
          id: this.data.group2.id,
        }
      }).then((res) => {
        let str = '失败'
        if(res.data.code==0){
          str = '成功'
        }
        wx.showToast({
          title: '删除'+str+'!',
          icon: 'success',
          duration: 900
        })
      })
    },
    examine(e){
      const id = e.currentTarget.dataset.id
      const examine = e.currentTarget.dataset.examine
      requestHasToken({
        url: 'api/go/dutch/updateExamine',
        data: {
          id,
          examine,
        }
      }).then((res) => {
        if (res.data.code == 0) {
          //多次下拉后 没有数据就不要加载了
          this.setData({
            'group2.examine':examine,
          })
          wx.showToast({
            title: '修改成功',
            icon: 'success',
            duration: 800
          })
        }
      })
    },
  },
  /* 2.监听组件本身的生命周期函数 */
  lifetimes: {
    created() {
      // console.log('组件被创建出来时');
    },
    attached() {
      this.setData({
        group2: this.properties.group
      })
      
      let content = this.data.group2.content
      if(content.length>38) {
        this.setData({
          'group2.content': content.substr(0, 38)+'...'
        })
      }
      // console.log('组件被添加到页面');

    },
    ready() {
      // console.log('组件被渲染出来');

    },
    moved() {
      // console.log('组件被移动到另一个节点');

    },
    detached() {
      // console.log('组件被移除掉');

    },
  }
})